package com.ssy.lingxi.member.merchant.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.ssy.lingxi.member.merchant.model.convert.JpaJsonToFileUploadVOConverter;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.FileUploadVO;
import com.ssy.lingxi.product.api.model.request.EnclosureUrlsRequest;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 会员拜访
 * @author hkm
 * @version 2.0.0
 * @date 2020-08-24
 */
@Data
@Entity
@Table(schema = "public", name = "ms_mc_member_visit")
public class MemberVisitDO implements Serializable {
    private static final long serialVersionUID = -1720444082119178256L;

    /**
     * 会员拜访id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="member_visit_seq")
    @SequenceGenerator(sequenceName="ms_mc_member_visit_seq", name="member_visit_seq",allocationSize = 1)
    private Long id;

    /**
     * 拜访主题
     */
    @Column
    private String visitTheme;

    /**
     * 多对一双向关联会员
     */
    @JsonManagedReference
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "member_id")
    private MemberDO member;

    /**
     * 拜访类型,定义在 VisitTypeEnum中
     */
    @Column
    private Integer visitType;

    /**
     * 拜访级别,定义在 VVisitLevelEnum中
     */
    @Column
    private Integer visitLevel;

    /**
     * 拜访日期
     */
    @Column
    private Long visitDate;

    /**
     * 多对一双向关联用户
     */
    @JsonManagedReference
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "member_user_id")
    private MemberUserDO memberUser;

    /**
     * 同行人
     */
    @Column
    private String peer;

    /**
     * 拜访备注
     */
    @Column
    private String visitRemark;

    /**
     * 拜访附件
     */
    @Convert(converter = JpaJsonToFileUploadVOConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<FileUploadVO> visitAttachments;

    /**
     * 创建人ID
     */
    @Column
    private Long createMemberRoleId;

    /**
     * 创建会员ID
     */
    @Column
    private Long createMemberId;

    /**
     * 创建时间
     */
    @Column
    private Long createTime;

    /**
     * 更新时间
     */
    @Column
    private Long updateTime;

}
